var wechat = require('wechat-enterprise');
var wechatAPI = require('wechat-enterprise-api');  //微信公共平台企业号版主动调用API
/**
 * 配置企业微信的信息
 * corpId: 企业编号
 * Secret="IE1gVIY30pJyb3uueVMkWj7K5205lp3PJ90JWgg1e2c"
 * AgentId =1000004  #应用id
 */
var wxconfig = {
    AgentId: '1000002',
    Secret: 'IE1gVIY30pJyb3uueVMkWj7K5205lp3PJ90JWgg1e2c',
    corpId: 'wxd4f3d283d0b7146c'
};
// 构造实例
var wechatApi = new wechatAPI('wxd4f3d283d0b7146c', 'IE1gVIY30pJyb3uueVMkWj7K5205lp3PJ90JWgg1e2c', '1000002');
 // 获取用户信息

 wechatApi.getUser("030523",function(e,res){
     console.log(res);
 })
 var msgTo={
   "touser": "030523",
  // "toparty": " PartyID1 | PartyID2 ",
 // "totag": " TagID1 | TagID2 "
 }
var msgBody=  {
   // "agentid": 1000002,
   "msgtype": "text",
   "text": {
     "content": "报警信息: 机器人车间温度25度；湿度56%; 运行时间3.4小时，<a href='http://dd.scetc.edu.cn'>详细信息</a>"
  },
   "safe":"0"
  }
  wechatApi.send(msgTo, msgBody, function(err,res) {
    console.log(err);
    console.log(res);
  });
/*
wechatApi.getUser('030523', function (err, data, res) {
  // response
   console.log(res)
});
*/
